//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "CallSpecifiedPathwiseMultiProduct.h"
using namespace Cephei::QL::Models::Marketmodels::Products::Pathwise;
#include <gen/QL/Models/Marketmodels/EvolutionDescription.h>
#include <gen/QL/Models/Marketmodels/CurveState.h>
#include <gen/QL/Models/Marketmodels/MarketModelPathwiseMultiProduct.h>
using namespace Cephei::QL::Models::Marketmodels;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct>& childNative, Object^ owner) : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
#ifdef HANDLE
	_phCallSpecifiedPathwiseMultiProduct = NULL;
#endif
	_ppCallSpecifiedPathwiseMultiProduct = &childNative;
    _ppMarketModelPathwiseMultiProduct = new boost::shared_ptr<QuantLib::MarketModelPathwiseMultiProduct> (boost::dynamic_pointer_cast<QuantLib::MarketModelPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct));
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (QuantLib::CallSpecifiedPathwiseMultiProduct& childNative, Object^ owner) : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
#ifdef HANDLE
	_phCallSpecifiedPathwiseMultiProduct = NULL;
#endif
	_ppCallSpecifiedPathwiseMultiProduct = new boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct> (&childNative);
    _ppMarketModelPathwiseMultiProduct = new boost::shared_ptr<QuantLib::MarketModelPathwiseMultiProduct> (boost::dynamic_pointer_cast<QuantLib::MarketModelPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct));
    _CallSpecifiedPathwiseMultiProductOwner = owner;
    _MarketModelPathwiseMultiProductOwner = owner;
}

Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (CCallSpecifiedPathwiseMultiProduct^ copy) : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
#ifdef HANDLE
	_phCallSpecifiedPathwiseMultiProduct = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppCallSpecifiedPathwiseMultiProduct = new boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct> (copy->GetShared());
        _ppMarketModelPathwiseMultiProduct = new boost::shared_ptr<QuantLib::MarketModelPathwiseMultiProduct> (boost::dynamic_pointer_cast<QuantLib::MarketModelPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct));
    }
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (PLATFORM::Type^ t) : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
#ifdef HANDLE
	_phCallSpecifiedPathwiseMultiProduct = NULL;
#endif
	if (!t->IsSubclassOf(CCallSpecifiedPathwiseMultiProduct::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (QuantLib::Handle<QuantLib::CallSpecifiedPathwiseMultiProduct>& childNative, Object^ owner)  : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
	_phCallSpecifiedPathwiseMultiProduct = &childNative;
	_ppCallSpecifiedPathwiseMultiProduct = &static_cast<boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct>>(childNative.currentLink());
    _ppMarketModelPathwiseMultiProduct = new boost::shared_ptr<QuantLib::MarketModelPathwiseMultiProduct> (boost::dynamic_pointer_cast<QuantLib::MarketModelPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct));
    _CallSpecifiedPathwiseMultiProductOwner = owner;
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (QuantLib::Handle<QuantLib::CallSpecifiedPathwiseMultiProduct> childNative)  : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
	_phCallSpecifiedPathwiseMultiProduct = &childNative;
	_ppCallSpecifiedPathwiseMultiProduct = &static_cast<boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct>>(childNative.currentLink());
    _ppMarketModelPathwiseMultiProduct = new boost::shared_ptr<QuantLib::MarketModelPathwiseMultiProduct> (boost::dynamic_pointer_cast<QuantLib::MarketModelPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct));
}
#endif
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::CCallSpecifiedPathwiseMultiProduct (QuantLib::CallSpecifiedPathwiseMultiProduct childNative)  : CMarketModelPathwiseMultiProduct(CCallSpecifiedPathwiseMultiProduct::typeid)
{
#ifdef HANDLE
	_phCallSpecifiedPathwiseMultiProduct = NULL;
#endif
	_ppCallSpecifiedPathwiseMultiProduct = new boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct> (new QuantLib::CallSpecifiedPathwiseMultiProduct (childNative));
    _ppMarketModelPathwiseMultiProduct = new boost::shared_ptr<QuantLib::MarketModelPathwiseMultiProduct> (boost::dynamic_pointer_cast<QuantLib::MarketModelPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct));
}
#endif

Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::~CCallSpecifiedPathwiseMultiProduct ()
{
    if (_ppCallSpecifiedPathwiseMultiProduct != NULL)
    {
	    delete _ppCallSpecifiedPathwiseMultiProduct;
        _ppCallSpecifiedPathwiseMultiProduct = NULL;
    }
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::!CCallSpecifiedPathwiseMultiProduct ()
{
    if (_ppCallSpecifiedPathwiseMultiProduct != NULL)
    {
	    delete _ppCallSpecifiedPathwiseMultiProduct;
    }
}
QuantLib::CallSpecifiedPathwiseMultiProduct& Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::GetReference ()
{
    if (_ppCallSpecifiedPathwiseMultiProduct == NULL) throw REFNEW NativeNullException ();
	return **_ppCallSpecifiedPathwiseMultiProduct;
}
boost::shared_ptr<QuantLib::CallSpecifiedPathwiseMultiProduct>& Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::GetShared ()
{
    if (_ppCallSpecifiedPathwiseMultiProduct == NULL) throw REFNEW NativeNullException ();
	return *_ppCallSpecifiedPathwiseMultiProduct;
}
QuantLib::CallSpecifiedPathwiseMultiProduct* Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::GetPointer ()
{
    if (_ppCallSpecifiedPathwiseMultiProduct == NULL) throw REFNEW NativeNullException ();
	return &**_ppCallSpecifiedPathwiseMultiProduct;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::CallSpecifiedPathwiseMultiProduct>& Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::GetHandle ()
{
	if (_phCallSpecifiedPathwiseMultiProduct == NULL)
	{
		_phCallSpecifiedPathwiseMultiProduct = new Handle<QuantLib::CallSpecifiedPathwiseMultiProduct> (*_ppCallSpecifiedPathwiseMultiProduct);
	}
	return *_phCallSpecifiedPathwiseMultiProduct;
}
#endif
bool Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::HasNative () 
{
	return (_ppCallSpecifiedPathwiseMultiProduct != NULL);
}

Boolean Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::AlreadyDeflated::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppCallSpecifiedPathwiseMultiProduct)->alreadyDeflated ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::ICallSpecifiedPathwiseMultiProduct^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::DisableCallability::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	(*_ppCallSpecifiedPathwiseMultiProduct)->disableCallability ( );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::ICallSpecifiedPathwiseMultiProduct^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::EnableCallability::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	(*_ppCallSpecifiedPathwiseMultiProduct)->enableCallability ( );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::IEvolutionDescription^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::Evolution::get ()
{
    try
    {
    	QuantLib::EvolutionDescription& _rv = (QuantLib::EvolutionDescription&)(*_ppCallSpecifiedPathwiseMultiProduct)->evolution ( );   
        Cephei::QL::Models::Marketmodels::CEvolutionDescription^ _nrv = REFNEW Cephei::QL::Models::Marketmodels::CEvolutionDescription (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
UInt64 Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::MaxNumberOfCashFlowsPerProductPerStep::get ()
{
    try
    {
    	QuantLib::Size _rv = (QuantLib::Size)(*_ppCallSpecifiedPathwiseMultiProduct)->maxNumberOfCashFlowsPerProductPerStep ( );   
        UInt64 _nrv = _rv; //c1
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
UInt64 Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::NumberOfProducts::get ()
{
    try
    {
    	QuantLib::Size _rv = (QuantLib::Size)(*_ppCallSpecifiedPathwiseMultiProduct)->numberOfProducts ( );   
        UInt64 _nrv = _rv; //c1
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::PossibleCashFlowTimes::get ()
{
    try
    {
    	std::vector<QuantLib::Time> _rv = (std::vector<QuantLib::Time>)(*_ppCallSpecifiedPathwiseMultiProduct)->possibleCashFlowTimes ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::IMarketModelPathwiseMultiProduct^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::Rebate::get ()
{
    try
    {
    	QuantLib::MarketModelPathwiseMultiProduct& _rv = (QuantLib::MarketModelPathwiseMultiProduct&)(*_ppCallSpecifiedPathwiseMultiProduct)->rebate ( );   
        Cephei::QL::Models::Marketmodels::CMarketModelPathwiseMultiProduct^ _nrv = REFNEW Cephei::QL::Models::Marketmodels::CMarketModelPathwiseMultiProduct (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::Products::Pathwise::ICallSpecifiedPathwiseMultiProduct^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::Reset::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	(*_ppCallSpecifiedPathwiseMultiProduct)->reset ( );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<UInt64>^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::SuggestedNumeraires::get ()
{
    try
    {
    	std::vector<QuantLib::Size> _rv = (std::vector<QuantLib::Size>)(*_ppCallSpecifiedPathwiseMultiProduct)->suggestedNumeraires ( );   
        Cephei::Core::IVector<UInt64>^ _nrv = REFNEW CoVector<UInt64> (REFNEW CUInt64Vector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::IMarketModelPathwiseMultiProduct^ Cephei::QL::Models::Marketmodels::Products::Pathwise::CCallSpecifiedPathwiseMultiProduct::Underlying::get ()
{
    try
    {
    	QuantLib::MarketModelPathwiseMultiProduct& _rv = (QuantLib::MarketModelPathwiseMultiProduct&)(*_ppCallSpecifiedPathwiseMultiProduct)->underlying ( );   
        Cephei::QL::Models::Marketmodels::CMarketModelPathwiseMultiProduct^ _nrv = REFNEW Cephei::QL::Models::Marketmodels::CMarketModelPathwiseMultiProduct (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

